<?php
namespace plugin\banmichaoqiangbizhi\admin; 
use plugin\banmichaoqiangbizhi\model\PluginBanmiBanmichaoqiangbizhiList; 
use plugin\banmichaoqiangbizhi\validate\ShoplistValidate;
use app\admin\common\Baseadmin;
use think\facade\Db; 

class Shoplist extends Baseadmin
{
    
    
        public function   nav_lists(){ 
          $list = Db::name('plugin_banmi_banmichaoqiangbizhi_nav')->select()->toArray();
          $data['list'] = $list;
          
          ajaxmsg('ok', 200, $data);
        }
    
        public function   updates_bjsjxx(){  
             $request= (new ShoplistValidate())->IsCheck();
             $field=[];
             if ( !input('request.shop_name')) {
                    ajaxmsg('请输入标题', 0);  
             }  
             if (!input('request.shop_tag')) {
                    ajaxmsg('请输入标签', 0);  
             } 
             if (!input('request.nav_id')) {
                    ajaxmsg('请选择标签', 0);  
             } 
              if (!input('request.shop_img')) {
                    ajaxmsg('请选择图片', 0);  
             } 
             $map=[
                  ['id',	'='   ,    input('request.id')  ],
                  ];
              $request['key_name']= $request['shop_name'] .$request['shop_tag'];
             $model =(new PluginBanmiBanmichaoqiangbizhiList())->updates($map,$request,$field);
              if($model){
               ajaxmsg('更新成功', 200);
              }
               ajaxmsg('更新失败', 0);  
      }
      
       public function   updates_add(){  
             $request= (new ShoplistValidate())->IsCheck();
             $field=[];
             $request['status'] =2;
             if ( !input('request.shop_name')) {
                    ajaxmsg('请输入标题', 0);  
             }  
             if (!input('request.shop_tag')) {
                    ajaxmsg('请输入标签', 0);  
             } 
             if (!input('request.nav_id')) {
                    ajaxmsg('请选择标签', 0);  
             } 
              if (!input('request.shop_img')) {
                    ajaxmsg('请选择图片', 0);  
             } 
             
             $request['creation_ip']=request()->ip();
             $request['creation_time']=time();
             $request['key_name']= $request['shop_name'] .$request['shop_tag'];
             $model =(new PluginBanmiBanmichaoqiangbizhiList())->adds($request,$field);
              if($model){
               ajaxmsg('添加成功', 200);
              }
               ajaxmsg('更新失败', 0);  
      }
     
     
      public function   finds_cxsjxq(){  
             $request= (new ShoplistValidate())->IsCheck();
             $field="id,nav_id,shop_name,shop_img,shop_tag,sort,status,creation_time,uid,creation_ip";
         
                  $map=[
                  ['id',	'='   ,   $request['id'] ],
                  ];
             $model =(new PluginBanmiBanmichaoqiangbizhiList())->finds($map,$field);
             $data['find']=$model;
             ajaxmsg('ok', 200,$data);  
      }
       
      /**
      * @notes  商家列表 
      * @variable   
      * @date 2022-12-03 16:53:30
      * @author 半米科技低代码一键生成
      */
      public function   paginate_sjlb(){  
             $request= (new ShoplistValidate())->IsCheck();
             $field="id,nav_id,shop_name,shop_img,sort,status,creation_time,uid,creation_ip,shop_tag";
         
                  $map=[
                  ['status',	'>='   ,    0 ],
                  ];
             $model =(new PluginBanmiBanmichaoqiangbizhiList())->paginate($map,$field);
             $data['list']=$model;
             ajaxmsg('ok', 200,$data);  
      }
       
      /**
      * @notes  删除商家 
      * @variable  id=id;status=; 
      * @date 2022-12-04 20:00:00
      * @author 半米科技低代码一键生成
      */
      public function   updates_scsj(){  
             $request= (new ShoplistValidate())->IsCheck('scsj');
             $field=["status"];
             $request['status']= -1;
             $map=[
                  ['id',	'='   ,    input('request.id')  ],
                  ];
             $model =(new PluginBanmiBanmichaoqiangbizhiList())->updates($map,$request,$field);
              if($model){
    
       
               ajaxmsg('更新成功', 200);
              }
               ajaxmsg('更新失败', 0);  
      }
       
      /**
      * @notes  置顶 
      * @variable  id=id;sort=sort; 
      * @date 2022-12-05 17:59:45
      * @author 半米科技低代码一键生成
      */
      public function   updates_zd(){  
             $request= (new ShoplistValidate())->IsCheck('zd');
             $field=["sort"];
              $map=[
                  ['id',	'='   ,    input('request.id')  ],
                  ];
             $model =(new PluginBanmiBanmichaoqiangbizhiList())->updates($map,$request,$field);
              if($model){
               ajaxmsg('更新成功', 200);
              }
               ajaxmsg('更新失败', 0);  
      }
           /**
      * @notes  审核拒绝 
      * @variable  id=id;status=; 
      * @date 2022-12-05 18:29:02
      * @author 半米科技低代码一键生成
      */
      public function   updates_jujue(){  
           
         
             $text =input('request.text');
             $map=[
                  ['id',	'='   ,    input('request.id')  ],
                  ];
            //  $model =(new PluginBanmiBanmichaoqiangbizhiList())->updates($map,$request,$field);
             
           $model =  (new PluginBanmiBanmichaoqiangbizhiList())->where($map)->update(['status' =>0 , 'refuse_text' =>$text  ]);
             
              if($model){
               ajaxmsg('更新成功', 200);
              }
               ajaxmsg('更新失败', 0);  
      }  
      /**
      * @notes  审核通过 
      * @variable  id=id;status=; 
      * @date 2022-12-05 18:29:02
      * @author 半米科技低代码一键生成
      */
      public function   updates_shtg(){  
             $request= (new ShoplistValidate())->IsCheck('shtg');
             $field=["status"];
             $request['status']= 2;
             $map=[
                  ['id',	'='   ,    input('request.id')  ],
                  ];
                  
             $model =(new PluginBanmiBanmichaoqiangbizhiList())->updates($map,$request,$field);
              if($model){
               ajaxmsg('更新成功', 200);
              }
               ajaxmsg('更新失败', 0);  
      }
       
      /**
      * @notes  
      * @variable  
      * @date 2022-12-05 19:30:10
      * @author 半米科技低代码一键生成
      */
      public function   paginate_cxsj(){  
             $request= (new ShoplistValidate())->IsCheck('cxsj');
             $field="id,nav_id,shop_name,shop_img,shop_tag,creation_ip,uid,creation_time,status,sort";
             $map=[
                   ['uid',	'='   ,    input('request.uid')  ],
                  ];
                  $map['status'] =2;
             $model =(new PluginBanmiBanmichaoqiangbizhiList())->paginate($map,$field);
             $data['list']=$model;
             ajaxmsg('ok', 200,$data);  
      }
      //控制器方法
    
    
    
}